<template>
  <div class="backTopName">
    <div class="backTopName_left van-ellipsis" @click="toBackOn">
      <van-icon name="arrow-left" size=".6rem" />
<!--      <div class="backTopName_name">{{ data.name || 0 }}</div>-->
      <div class="backTopName_name">返回</div>
    </div>
    <div class="backTopName_middle">{{chatList.receiveName}}</div>
    <div class="backTopName_right" v-if="show">
      <div v-if="userOrDoctor == 1" @click="toDialogConfirm">
        {{ isEndConsult }}
      </div>
      <div v-else>...</div>
    </div>
  </div>
</template>

<script>
import { Dialog } from "vant";
export default {
  name: "backTopName",
  props: {
    show: {
      type: Boolean,
      default() {
        return true;
      },
    },
    chatList: {
      default() {
        return [];
      },
      type: Array,
    },
  },
  data() {
    return {
      isEndConsult: "结束会诊",
      isEnd: false,
    };
  },
  computed: {
    userOrDoctor() {
      return this.$store.state.user_type;
    },
  },
  methods: {
    toBackOn() {
      this.$router.back();
    },
    toDialogConfirm() {
      if (!this.isEnd) {
        Dialog.confirm({
          message: "确定结束会诊",
          className: "dailog",
        })
          .then(() => {
            // on confirm
            this.isEndConsult = "已结束会诊";
            this.isEnd = true;
          })
          .catch(() => {
            // on cancel
          });
      }
    },
  },
};
</script>

<style lang="scss" scope>
.van-dialog__content--isolated {
  min-height: 60px;
}
.van-dialog__message {
  font-size: 18px;
  font-weight: 550;
}

.backTopName {
  height: 50px;
  background-color: #efefef;
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;

  &_right {
    font-size: 15px;
  }
  &_middle {
    font-size: 15px;
    justify-content:center;
  }
  &_left {
    display: flex;
    align-items: center;
    max-width: 150px;
  }

  &_name {
    margin-left: 5px;
    font-size: 16px;

    //overflow: hidden;
    white-space: nowrap;
  }
}
</style>
